include("shared.lua")

language.Add("ag3", "AG-3 Satellite")

ENT.cycleInterval = 0.03

local glowMaterial = Material("sprites/portalglow")
local glowSize = 0

function ENT:Think()
  self:NextThink(CurTime() + self.cycleInterval)

  if(self:IsCharging()) then
    glowSize = 75 * self:GetNetworkedFloat("charge", 0)
  elseif(self:IsFiring() && glowSize > 0) then
    glowSize = math.max(glowSize - 3, 0)
  else
    glowSize = 0
  end

  return true
end

function ENT:Draw()
   self.BaseClass.Draw(self, false)
   
   if(glowSize < 1) then
      return
   end
      
   render.SetMaterial(glowMaterial)
   render.DrawSprite(self:GetEmitterPos(), 
                     glowSize, glowSize, 
                     self:GetBeamColour())
end
